package com.baiwei.vpnapi.entity.reqentity;

import com.baiwei.vpnapi.exception.AccountException;
import com.baiwei.vpnapi.exception.BusinessEnum;
import com.baiwei.vpnapi.utils.FieldChecker;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.NotNull;

/**
 * @program: vpnapi
 * @description: 注册输入
 * @author: Mr. Stone
 * @create: 2020-02-26 14:00
 **/

@Data
public class UserCreateInput implements Validatable {

    private String username;
    private String password;
    private String channelNo;
    private String inviteCode;

    @Override
    public void validation() {

        if(username == null && username.length() == 0) {
            throw new AccountException(BusinessEnum.EMAIL_EMPTY);
        }
        if(password == null && password.length() == 0) {
            throw new AccountException(BusinessEnum.PASSWORD_EMPTY);
        }
//        if(!FieldChecker.isValidEmail(username)) {
//            throw new AccountException(BusinessEnum.EMAIL_FORMAT_ERR);
//        }
    }

    public String getInviteCode() {
        return inviteCode;
    }

    public void setInviteCode(String inviteCode) {
        this.inviteCode = inviteCode;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String email) {
        this.username = email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getChannelNo() {
        return channelNo;
    }

    public void setChannelNo(String channelNo) {
        this.channelNo = channelNo;
    }

    public UserCreateInput(String username, String password, String channelNo) {
        this.username = username;
        this.password = password;
        this.channelNo = channelNo;
    }

    public UserCreateInput() {
    }
}
